package com.nobody.facepk.persist.type;

import java.util.HashMap;
import java.util.Map;

public class Config {
	private Map<String, String> configMap = new HashMap<String, String>();
	
	public Config() {}
	
	public void setValue(String key, String value) {
		this.configMap.put(key, value);
	}
	
	public String getString(String key) {
		return this.configMap.get(key);
	}
	
	public long getLong(String key, long def) {
		try {
			return Long.parseLong(getString(key));
		} catch (Exception e) {
			return def;
		}
	}
	
	public int getInteger(String key, int def) {
		try {
			return Integer.parseInt(getString(key));
		} catch (Exception e) {
			return def;
		}
	}
	
	public Map<String, String> getConfigMap() {
		return this.configMap;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj==null || !(obj instanceof Config)) return false;
		Config c = (Config)obj;
		return this.configMap.equals(c.configMap);
	}
}
